package com.example.module_web.view.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.module_web.R;
import com.example.module_web.adapter.ConsignmentAdapter;
import com.example.module_web.base.BaseFragmentB;
import com.example.module_web.beans.Consignment;
import com.example.module_web.viewmodule.NetData_Web;

import java.util.List;

/**
 * Created by Administrator on 2018/2/19.
 */

public class Fragment_02 extends FormFragment {

    private RecyclerView mRecyConsignment;
    private List<Consignment> mConsignments;

    @Override
    protected int setLayoutId() {
        return R.layout.web_fragment_02;
    }

    @Override
    protected void initView(View view) {
        mRecyConsignment = view.findViewById(R.id.web_frag02_recy_consignment);
    }

    @Override
    protected void initEvent(Context context, Bundle savedInstanceState) {
        setupRecyclerData(context);
    }

    public void setupRecyclerData(Context context) {
        setupRecycler(context,mRecyConsignment);
        loadNetData(context);
    }

    private void loadNetData(final Context context) {
        NetData_Web.getInstance().getConsignments(context, "Consignment", new NetData_Web.Singer<List<Consignment>>() {
            @Override
            public void success(List<Consignment> consignments) {
                mConsignments = consignments;
                ConsignmentAdapter consignmentAdapter = new ConsignmentAdapter(context, consignments);
                mRecyConsignment.setAdapter(consignmentAdapter);
            }

            @Override
            public void failed(String s) {

            }
        });
    }
}
